﻿package scripts
{
	import flash.accessibility.Accessibility;
	import flash.accessibility.AccessibilityProperties;
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.system.Capabilities;
	import flash.events.MouseEvent;
	public class BaseClass extends MovieClip
	{
		protected var displayComponent:Class;
		protected var _component:DisplayObject;
		private var accessProps:AccessibilityProperties;
		public function BaseClass(dc:Class = null)
		{
			super();
			tabChildren=true;
			buttonMode = true;
			useHandCursor = true;
			
			accessProps= new AccessibilityProperties();
			
			//---------------duming
			if(dc){
				displayComponent = dc
				createNewComponent();
			}
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		public function set accDesc(str:String):void{
			this.accessProps.name=str;
			accessibilityProperties = accessProps;
			if (Capabilities.hasAccessibility) {
				Accessibility.updateProperties();
			}
		}
		public function get accDesc():String{
			return this.accessProps.name;
		}
		
		private function createNewComponent():void
		{
			// TODO Auto Generated method stub
			_component = new displayComponent();
			this.addChild(_component);
		}
		
		public function init(e:Event):void {
			var e:Event = new Event("TAB_ME");
			dispatchEvent(e);
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// NOT NEEDED
		}
		public function setEnable():void {
			buttonMode = true;
			useHandCursor = true;
			this.tabEnabled=true;
			addEventListener(MouseEvent.MOUSE_OVER, rollOn);
			addEventListener(MouseEvent.MOUSE_OUT, rollOff);
			addEventListener(MouseEvent.MOUSE_DOWN, mouseClickDown);
			addEventListener(MouseEvent.MOUSE_UP, mouseClickUp);
			addEventListener(MouseEvent.CLICK, clickHandler);
		}
		public function setDisable():void {
			buttonMode = false;
			useHandCursor = false;
			this.tabEnabled=false;
			removeEventListener(MouseEvent.MOUSE_OVER, rollOn);
			removeEventListener(MouseEvent.MOUSE_OUT, rollOff);
			addEventListener(MouseEvent.MOUSE_DOWN, mouseClickDown);
			removeEventListener(MouseEvent.CLICK, clickHandler);
		}
		public function rollOn(e:Event):void{
			//trace("rollOn");
		}
		public function rollOff(e:Event):void{
			//trace("rollOff");
		}
		public function mouseClickDown(e:Event):void{
			//trace("MouseDown");
		}
		public function mouseClickUp(e:Event):void{
			//trace("MouseUP");
		}
		public function clickHandler(e:Event):void{
			//trace("Clicked");
		}

	}
}